import request from '@/utils/request'
import qs from "qs"
export default {

    pageInfo(pageNum, pageSize, categoryParentId) {
        return request({
            url: '/api-goods/category/childrenListAll',
            method: 'get',
            params: {
                pageNum,
                pageSize,
                categoryParentId
            }
        })
    },
    // 递归获取所有商品分类
    getCategoryList() {
        return request({
            url: '/api-goods/category/listAllVo',
            method: 'get',
        })
    },

    // 获取级别
    getCategoryLevel(categoryId) {
        return request({
            url: '/api-goods/category/getCategoryLevel?categoryId=' + categoryId,
            method: 'get',
        })
    },

    // 插入表单
    insertForm(category) {
        var data = qs.stringify(category);
        return request({
            url: '/api-goods/category/insertForm',
            method: 'post',
            data
        })
    },

    // 获取分类名
    getCategoryName(categoryId) {
        return request({
            url: '/api-goods/category/getCategoryName?categoryId=' + categoryId,
            method: 'get',
        })
    },

    // 获取全部数据
    getCategoryAll() {
        return request({
            url: '/api-goods/category/getCategoryAll',
            method: 'get',
        })
    },

    // 根据分类名查询
    getCategoryValue(categoryName) {
        return request({
            url: '/api-goods/category/getCategoryValue?categoryName=' + categoryName,
            method: 'get',
        })
    },

    // 修改数据
    updateParentId(category) {
        var data = qs.stringify(category);
        return request({
            url: '/api-goods/category/updateParentId',
            method: 'put',
            data
        })
    },

    // 根据id查数据
    getListAllById(categoryId) {
        return request({
            url: '/api-goods/category/listAllById',
            method: 'get',
            params: { categoryId }
        })
    },
     // 根据id查数据
     getListById(parentId) {
        return request({
            url: '/api-goods/category/list/parentId',
            method: 'get',
            params: { parentId }
        })
    },

    // 根据id删除数据
    deleteList(id) {
        return request({
            url: `/api-goods/category/deleteList/${id}`,
            method: 'delete'
        })
    },

    getListByLevelPage(pageNum, pageSize, categoryLevel) {
        return request({
            url: '/api-goods/category/listAllByLevelPage',
            method: 'get',
            params: {
                pageNum,
                pageSize,
                categoryLevel
            }
        })
    }
}